import store from '../store'
let timerFun = null;

export function toLogin(hintText){
	clearTimeout(timerFun);
	timerFun = null;
	timerFun = setTimeout(function() {
		uni.showModal({
			title: '登录提示',
			content: hintText || '登录以后可体验完整功能',
			cancelColor: '#000000',
			confirmColor: '#526BB1',
			success: function (res) {
				if (res.confirm) {
				  uni.navigateTo({
					 url: '/pages/login/login'
				  })
				} else if (res.cancel) {
					uni.reLaunch({
						url: '/pages/index/index'
					})
				}
			}
		});
	}, 300);
}

export function outLogin(){
	store.commit('setToken',null);
	store.commit('setUserIdData',null);
	store.commit('setRegnoInfo',null);
	store.commit('setParentRegnoInfo',null);
}

export default { toLogin,outLogin }